<%@ page language="java"%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import=" BE.Producto"%>
<%@ page import=" BE.Lineaproducto"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-nested" prefix="nested" %>
<html:html locale="true">
<head>
    <title>Productos</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.6, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon" href="mobProductos/Images/WebClipIcon.png">
    <link rel="stylesheet" href="mobProductos/mobProductos.css">
    <link rel="stylesheet" href="mobProductos/Parts/Transitions.css">
    <script type="text/javascript" src="mobProductos/Parts/setup.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/mobProductos.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/Header.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/utilities.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/Transitions.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/StackLayout.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/Browser.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/Text.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/PushButton.js" charset="utf-8"></script>
    <script type="text/javascript" src="mobProductos/Parts/ButtonHandler.js" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
    <%
        String strMensaje = "";

        if ((request != null) && (request.getAttribute("strMensaje") != null) && (!request.getAttribute("strMensaje").equals(""))) {
            strMensaje = (String) request.getAttribute("strMensaje");
        }

        List<Producto> vectorProducto=null;
        if(session.getAttribute("arrProductosBusqueda")!=null) {
            vectorProducto=(List<Producto>)session.getAttribute("arrProductosBusqueda");
        };
        List<Integer> vectorBonificacion=null;
        if(session.getAttribute("arrBonificaciones")!=null) {
            vectorBonificacion=(List<Integer>)session.getAttribute("arrBonificaciones");
        };

        List<Lineaproducto> vectorLineaProducto=null;
        if(session.getAttribute("arrLineaProducto")!=null) {
            vectorLineaProducto=(List<Lineaproducto>)session.getAttribute("arrLineaProducto");
        };

        List<String> vectorCantidades=new ArrayList();
        if(session.getAttribute("arrCantidades")!=null)
        {
            vectorCantidades = (List<String>)session.getAttribute("arrCantidades");
        }

    %>

   var parks=new Array(<%= vectorProducto.size() %>);

   <%

   String strBonificacion="";
   String strCantidad="";
   int j=0;
     for(int i=0; i<vectorProducto.size(); i++)
   {
        if((vectorBonificacion!=null)&&(vectorBonificacion.size()>0)&&(j<vectorBonificacion.size()))
        {
            if (vectorBonificacion.get(j)==(vectorProducto.get(i)).getSrlIdproducto())
            {
            strBonificacion="Bonificacion asociada: "+ vectorBonificacion.get(j+1) + "x" + vectorBonificacion.get(j+2);
            j=j+3;
            }
            else
            {
            strBonificacion= "No tiene bonificaciones asociadas";
            }
        }
        else
        {
            strBonificacion= "No tiene bonificaciones asociadas";
        }

        if(i<vectorCantidades.size())
        {
            strCantidad= vectorCantidades.get(i);
        }
        else
            strCantidad="";
      
       out.println("parks["+ i +"]  = new Array("+"\"" +i+"\""+","+"\"" +(vectorProducto.get(i)).getCvNombre() + "\""+","+"\""+(vectorProducto.get(i)).getCvObservacion()+"\""+","+"\""+(vectorProducto.get(i)).getCvDescripcion()+"\""+","+"\""+(vectorProducto.get(i)).getRlPreciocosto().doubleValue()+"\""+","+"\""+(vectorProducto.get(i)).getIntStockminimo()+" und"+"\""+","+"\""+(vectorProducto.get(i)).getCvImagen()+"\""+","+"\""+(vectorProducto.get(i)).getSrlIdproducto()+"\""+","+"\""+ strBonificacion +"\""+","+"\""+ strCantidad +"\""+");");
   }
   %>


    var arrListaProductos = new Array(<%= 2*vectorProducto.size() %>);

	addEventListener('load', function() {
		setTimeout(hideAddressBar, 0);
	}, false);
	function hideAddressBar() {
		window.scrollTo(0, 1);
	}
    </script>
    <script type="text/javascript" src="mobProductos/Parts/List.js" charset="utf-8"></script>
</head>
<body onload="load();">
   <html:form action="mobProductos">
    <input type="hidden" id="mensaje" value="<%= strMensaje%>">
    <input type="hidden" name="arrListaPedido" id="arrListaPedido" value=arrListaProdutos>

    <div apple-part="com.apple.Dashcode.part.browser" id="browser">
        <div apple-part="com.apple.Dashcode.part.header" apple-part-locked="true" apple-style="image-theme: 2; image-shape: 3; image-button-type: 3; image-opacity: 1.00; image-top-color: 0.592156887,0.65882355,0.741176486,1; image-bottom-color: 0.411764711,0.513725519,0.635294139,1; image-radius: 0,0,0,0; image-border: 0; image-border-color: 0.529399991,0.529399991,0.529399991,1; image-border-width: 0; shine-on: 1; shine-strength: 0.08; shine-alpha-level: 0.00; shine-height: 0.50; glass-arc-height: 0.00; image-include-custom: 1; image-custom-image-path: header.png; image-custom-center: 1; image-custom-resize: 2; shadow-include-shadow: 0;" apple-group="header" id="header">
            <div apple-part="com.apple.Dashcode.part.gobackbutton" id="back_button" class="apple-no-children back_button_template dashcode-header-backbutton" apple-part-locked="true" apple-text-overflow="ellipsis" apple-style="image-theme: 0; image-shape: 11; image-button-type: 0; image-opacity: 1.00; image-top-color: 0,0,0,1; image-bottom-color: 0.239130437,0.239130437,0.239130437,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.17; shine-alpha-level: 0.04; shine-height: 0.50; glass-arc-height: 0.00; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; shadow-include-shadow: 0;" apple-template="true"></div>
            <!--<div apple-part="com.apple.Dashcode.part.pushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 0; image-shape: 3; image-button-type: 0; image-opacity: 1.00; image-top-color: 0.950713336,0.737178624,0.174853131,1; image-bottom-color: 1,1,1,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.17; shine-alpha-level: 0.04; shine-height: 0.50; glass-arc-height: 0.00; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; shadow-include-shadow: 0;" id="btnListo"></div>-->
            <html:submit property="submit" onclick="return terminoElegirProductos(event)" styleId="btnListo">
                  <bean:message key="button.CargarLineaPedido"/>
            </html:submit>
        </div>
        <div apple-part="com.apple.Dashcode.part.StackLayout" apple-part-locked="true" id="stackLayout">
            <div id="listLevel" apple-part-locked="true">
                <div apple-part="com.apple.Dashcode.part.box" id="boxTop">
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtCantProductos"></div>
                    <!--<div apple-part="com.apple.Dashcode.part.lozengeleftpushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 2; image-shape: 7; image-button-type: 0; image-opacity: 1.00; image-top-color: 0.290196091,0.423529416,0.607843161,1; image-bottom-color: 1,1,1,1; image-radius: 14,0,14,0; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.06; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="btnTodosUp"></div>-->
                    <html:submit property="submit" onclick="recogerProductos(event)" styleId="btnTodosUp">
                        <bean:message key="button.BuscarTodosDOWN"/>
                    </html:submit>

                    <div apple-part="com.apple.Dashcode.part.lozengepushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 2; image-shape: 8; image-button-type: 0; image-opacity: 1.00; image-top-color: 0.290196091,0.423529416,0.607843161,1; image-bottom-color: 1,1,1,1; image-radius: 0,14,0,14; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.06; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="btnBuscarUp"></div>


                    <div apple-part="com.apple.Dashcode.part.rectanglewebshape" apple-style="image-theme: 2; image-shape: 3; image-button-type: 3; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.615400016,0.615400016,0.615400016,1; image-radius: 0,0,0,0; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.06; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="rectangleShape">
                    </div>
                </div>
                <ul apple-part="com.apple.Dashcode.part.edgeToEdgeList" id="list">
                    <li id="listRowTemplate" class="listRowTemplate_template" apple-template="true">
                        <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children rowTitle_template" apple-text-overflow="ellipsis" id="rowTitle"></div>
                        <div apple-part="com.apple.Dashcode.part.box" id="rowArrow" class="rowArrow_template"></div>
                        <input type="text" name="" value="" class="apple-textfield apple-no-children textField_template" apple-part="com.apple.Dashcode.part.textfield" id="textField" onkeypress="return isNumberKey(event)" onkeyup="calcularTotalProductos()">
                        <img src="Images/Image(106).jpg" id="imgField" class="imgField_template" onclick="popUpCantidad(event)">
                        <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children txtDescripcion_template" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtDescripcion"></div>
                        <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children txtStockLabel_template" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtStockLabel"></div>
                        <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children txtStockValor_template" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtStockValor"></div>
                    </li>
                </ul>
                <div apple-part="com.apple.Dashcode.part.box" id="boxBottom" apple-group="box2">
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtCantProductosBottom"></div>
                    <div apple-part="com.apple.Dashcode.part.lozengepushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 2; image-shape: 8; image-button-type: 0; image-opacity: 1.00; image-top-color: 0.290196091,0.423529416,0.607843161,1; image-bottom-color: 1,1,1,1; image-radius: 0,14,0,14; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.06; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="btnBuscarBottom"></div>
                    <div apple-part="com.apple.Dashcode.part.rectanglewebshape" apple-style="image-theme: 2; image-shape: 3; image-button-type: 3; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 0.615400016,0.615400016,0.615400016,1; image-radius: 0,0,0,0; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.06; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="rectangleShapeBottom">
                    </div>
                    <!--<div apple-part="com.apple.Dashcode.part.lozengeleftpushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 2; image-shape: 7; image-button-type: 0; image-opacity: 1.00; image-top-color: 0.290196091,0.423529416,0.607843161,1; image-bottom-color: 1,1,1,1; image-radius: 14,0,14,0; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.06; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="btnTodosUpBottom"></div>-->
                    <html:submit property="submit" onclick="recogerProductos(event)" styleId="btnTodosUpBottom">
                        <bean:message key="button.BuscarTodosDOWN"/>
                    </html:submit>
                </div>
            </div><div id="detailLevel" apple-part-locked="true">
                <div apple-part="com.apple.Dashcode.part.box" id="gbxStock1" apple-group="gbxStock1">
                    <img src="Images/Image(106).jpg" id="imgProducto">
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-text-overflow="ellipsis" id="detailTitle" apple-style="part-width-dependent: true;part-height-dependent: true;"></div>
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="detailLocation" apple-style="part-width-dependent: true;part-height-dependent: true;"></div>
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="detailDescription" apple-style="part-width-dependent: true;part-height-dependent: true;"></div>
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="detailLocation1"></div>
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtPrecio"></div>
                </div>
                <!--<div apple-part="com.apple.Dashcode.part.pushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 0; image-shape: 3; image-button-type: 0; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 1,1,1,1; image-radius: 8,8,8,8; image-border: 1; image-border-color: 0.674509823,0.674509823,0.674509823,1; image-border-width: 1; shine-on: 0; shine-strength: 0.17; shine-alpha-level: 0.04; shine-height: 0.50; glass-arc-height: 0.00; embossed-on: 0; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; shadow-include-shadow: 0;" id="btnDescuentosDesc"></div>-->
                <div apple-part="com.apple.Dashcode.part.pushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 0; image-shape: 3; image-button-type: 0; image-opacity: 1.00; image-top-color: 1,1,1,1; image-bottom-color: 1,1,1,1; image-radius: 8,8,8,8; image-border: 1; image-border-color: 0.674509823,0.674509823,0.674509823,1; image-border-width: 1; shine-on: 0; shine-strength: 0.17; shine-alpha-level: 0.04; shine-height: 0.50; glass-arc-height: 0.00; embossed-on: 0; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; shadow-include-shadow: 0;" id="btnBonificacion"></div>
                <div apple-part="com.apple.Dashcode.part.box" id="gbxStock" apple-group="settingsGroup">
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtStock"></div>
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtStockValue"></div>
                </div>
                <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtInfo" apple-style="part-width-dependent: true;part-height-dependent: true;"></div>
                <div apple-part="com.apple.Dashcode.part.box" id="rowArrow1" class=""></div>
                <!--<div apple-part="com.apple.Dashcode.part.box" id="rowArrow2" class=""></div>-->
            </div>
            <div id="detailDescuentos" apple-part-locked="true"></div>
            <div id="bonificaciones" apple-part-locked="true">

               <!-- <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtBonificaciones" apple-style="part-width-dependent: true;part-height-dependent: true;"></div>-->
                <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtInformacionBonificaciones" apple-style="part-width-dependent: true;part-height-dependent: true;">

                </div>
            </div><div id="buscar" apple-part-locked="true">
                <div apple-part="com.apple.Dashcode.part.box" id="box1" apple-group="box1">
                    <div apple-part="com.apple.Dashcode.part.pushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 2; image-shape: 3; image-button-type: 0; image-opacity: 1.00; image-top-color: 0.290196091,0.423529416,0.607843161,1; image-bottom-color: 1,1,1,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.00; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="btnLimpiar"></div>
                    <!--<div apple-part="com.apple.Dashcode.part.pushbutton" class="apple-no-children" apple-text-overflow="ellipsis" apple-style="image-theme: 2; image-shape: 3; image-button-type: 0; image-opacity: 1.00; image-top-color: 0.290196091,0.423529416,0.607843161,1; image-bottom-color: 1,1,1,1; image-radius: 5,5,5,5; image-border: 1; image-border-color: 0,0,0,0.2; image-border-width: 1; shine-on: 1; shine-strength: 0.50; shine-alpha-level: 0.25; shine-height: 0.50; glass-arc-height: 0.00; embossed-on: 1; embossed-depth: 1; embossed-shadow: 0.68; embossed-highlight: 0.3; image-include-custom: 1; shadow-include-shadow: 0;" id="btnBuscar"></div>-->
                    <html:submit property="submit" onclick="recogerProductos(event)" styleId="btnBuscar">
                  <bean:message key="button.BuscarProductos"/>
                </html:submit>
                </div>


                    <select name="lineaProducto" id="cbxLineaProducto">
                        <%
                           for (int i = 0; i < vectorLineaProducto.size(); i++) {
                           out.println("<option class=\"apple-hidden\" id=\"" + (vectorLineaProducto.get(i)).getCvNombre() + "\" value=\"" + (vectorLineaProducto.get(i)).getSrlLineaproducto() + "\">" + (vectorLineaProducto.get(i)).getCvNombre() + "</option>");
                            }
                        %>
                    </select>


                
                <div apple-part="com.apple.Dashcode.part.box"  id="gbxNombreBusqueda" apple-group="gbxStock1">
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="lblNombreBusqueda"></div>
                    <input type="text" name="nomProducto" value="" class="apple-textfield apple-no-children" apple-part="com.apple.Dashcode.part.textfield" id="txtNombreBusqueda">
                </div>
                <div apple-part="com.apple.Dashcode.part.box" id="gbxMin" apple-group="gbxStock2">
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="lblMin"></div>
                    <input type="text" name="Min" value="" class="apple-textfield apple-no-children" apple-part="com.apple.Dashcode.part.textfield" id="txtMin" onkeypress="return isNumberKey(event)">
                </div>
                <div apple-part="com.apple.Dashcode.part.box" id="gbxMax" apple-group="gbxStock3">
                    <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="lblMax"></div>
                    <input type="text" name="Max" value="" class="apple-textfield apple-no-children" apple-part="com.apple.Dashcode.part.textfield" id="txtMax" onkeypress="return isNumberKey(event)">
                </div>
                <div apple-part="com.apple.Dashcode.part.webtext" class="apple-text apple-no-children" apple-default-image-visibility="hidden" apple-text-overflow="ellipsis" id="txtInfoBuscar" apple-style="part-height-dependent: true;"></div>
            </div></div>
    </div>
    </html:form>
</body>
</html:html>
